package com.soho.mdi;

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

public class MyIcon extends JPanel {
	private Image image;
	private String title;
	public MyIcon(ImageIcon icon, String title){
		super();
		
		this.image = icon.getImage();
		this.title = title;
		this.setSize(50,50);
		this.setLayout(new BorderLayout());
		
		JLabel label = new JLabel(title,SwingConstants.CENTER);

		this.add(label, BorderLayout.SOUTH);
		this.setOpaque(false);
		this.setVisible(true);
	}
	
	public void paintComponent(Graphics g) {
	    super.paintComponent(g);
	    if (image != null) {
	        g.drawImage(image, 9, 0, this);                   
	    }
	}	
	
	public String getTitle(){
		return title;
	}
	
	public String toString(){
		return title;
	}
}
